#include "easytablewidget.h"
#include <QHeaderView>

EasyTableWidget::EasyTableWidget(QWidget *parent):QTableWidget(parent)
{
}
void EasyTableWidget::setTable(ResourceList* r)
{
    int count = r->count();
    if(count > 0)
    {
	QStringList l = ((Resource*)r->at(0))->getHeaders();
	setColumnCount(l.count());
	setHorizontalHeaderLabels(l);
	setRowCount(count);
	for(int i=0;i<count;i++)
	{
	    Resource * res = (Resource*)r->at(i);
	    QList<QTableWidgetItem*> items = res->getItems();
	    for(int j=0;j<items.count();j++)
	    {
		this->setItem(i,j,items.at(j));
	    }
	}
    }
}
